package pl.edu.mimuw.irs.rcp.controller.editor.simulation;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import pl.edu.mimuw.irs.core.model.analysis.Report;
import pl.edu.mimuw.irs.core.model.analysis.workflow.AnalysisWorkflow;
import pl.edu.mimuw.irs.core.model.design.net.IRSWorkflow;
import pl.edu.mimuw.irs.core.model.simulation.SimulationWorkflow;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-27
 */
public class SimulationEditorInput implements IEditorInput {

	// *** Attributes

	private SimulationWorkflow simulationWorkflow;
	private IRSWorkflow irsWorkflow;
	private AnalysisWorkflow analysisWorkflow;
	private Report report;
	private IProject project;
	public SimulationWorkflow getSimulationWorkflow() {
		if (simulationWorkflow == null) createNewSimulationWorkflow();
		return simulationWorkflow;
	}
	public void createNewSimulationWorkflow() {
		simulationWorkflow = new SimulationWorkflow(irsWorkflow, analysisWorkflow, report);
	}
	public Report getReport() {
		return report;
	}
	public IProject getProject() {
		return project;
	}
	
	// *** Constructors
	
	public SimulationEditorInput(IRSWorkflow workflow,
			AnalysisWorkflow analysisWorkflow, Report report, IProject project) {
		this.irsWorkflow = workflow;
		this.analysisWorkflow = analysisWorkflow;
		this.report = report;
		this.project = project;
	}
	
	// *** Methods

	@Override
	public boolean exists() {
		return true;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		// XXX Auto-generated method stub
		return null;
	}

	@Override
	public String getName() {
		// XXX Auto-generated method stub
		//return null;
		return "name...";
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		// XXX Auto-generated method stub
		return "Tooltip...";
	}

	@SuppressWarnings("unchecked")
	@Override
	public Object getAdapter(Class adapter) {
		if (adapter == Report.class) {
			return getReport();
		}
		return null;
	}
}
